<?php


class albumhomepagemodule_config {
	function form($object) {
		global $db;

		if (!defined('SYS_FORMS')) require_once(BASE.'subsystems/forms.php');
		exponent_forms_initialize();
		
		$form = new form();
		if (!isset($object->id)) {
			$object->items=5;
			$object->album_id=0;
			$object->linebreak=0;
		} else {
			$form->meta('id',$object->id);
		}
		
		// search any where to get all the article module
		$host=array();
		$sql="SELECT {$db->prefix}album.* FROM {$db->prefix}album";
		$data=$db->selectObjectsBySql($sql);
		
		foreach  ($data as $k=>$v)
		{
			$host[$v->id]=$v->name;
			if ($v->publisher != "")
				$host[$v->id] == $host[$v->id].= " - " . $v->publisher;
			if ($v->id==$object->album_id)
				$object->host_location_data=$v->id;
		}
		
		$form->register('items','Items',new textcontrol($object->items));
		$form->register('album_id',"Album",new dropdowncontrol($object->album_id,$host));
		$form->register('linebreak','Show break line',new checkboxcontrol($object->linebreak));
		$form->register('submit','',new buttongroupcontrol("Save",'',"Cancel"));
		
		return $form;
	}
	
	function update($values,$object) {
		$object->album_id = $values['album_id'];
		$object->items = $values['items'];
		if (isset($values['linebreak']))
			$object->linebreak= $values['linebreak'];
		else
			$object->linebreak=0;
		return $object;
	}
}

?>
